package com.luyue.zagj.activity.base;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.view.Window;
import android.view.WindowManager;

import com.luyue.zagj.BaseActivity;
import com.luyue.zagj.R;
import com.luyue.zagj.MainActivity;
import com.luyue.zagj.activity.home.ShowLocationActivity;
import com.luyue.zagj.application.MyApl;

import com.luyue.zagj.utils.SPutils;

public class SpalshActivity extends BaseActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {

        requestWindowFeature(Window.FEATURE_NO_TITLE);
        this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        super.onCreate(savedInstanceState);


        setContentView(R.layout.activity_spalsh);
            new Handler().postDelayed(new Runnable() {
                @Override
                public void run() {
                    //如果第一次启动 进入广告页
                    boolean isFirstOpen = (Boolean) SPutils.get(SpalshActivity.this, MyApl.FIRST_OPEN, false);
                    if (!isFirstOpen) {
                        enterAdActivity();
                    }else {
                        enterHomeActivity();
                    }
                }
            }, 2000);
    }

    private void enterHomeActivity() {
        Intent intent = new Intent(this, MainActivity.class);
        startActivity(intent);
        finish();
    }

    private void enterAdActivity() {
        Intent intent = new Intent(this, AdActivity.class);
        startActivity(intent);
        finish();
    }
}
